package org.csu.mypetstoreplus.vo;

import lombok.Data;
import org.csu.mypetstoreplus.entity.CartItem;
import org.csu.mypetstoreplus.entity.Inventory;
import org.csu.mypetstoreplus.entity.Item;
import org.csu.mypetstoreplus.entity.Product;

import java.math.BigDecimal;

@Data
public class CartItemVO {
    private String itemId;
    private String productId;
    private String name;
    private String attribute;
    private String description;
    private int quantity;
    private int maxQuantity;
    private String listPrice;
    private String totalCost;

    public CartItemVO(CartItem cartItem, Item item, Product product, Inventory inventory) {
        this.itemId = cartItem.getItemId();
        this.productId = cartItem.getProductId();
        this.name = product.getName();
        this.attribute = item.getAttribute1();
        this.description = product.getDescription();
        this.quantity = cartItem.getQuantity();
        this.maxQuantity = inventory.getQuantity();
        this.listPrice = String.valueOf(item.getListPrice());
        this.totalCost = String.valueOf(item.getListPrice().multiply(BigDecimal.valueOf(cartItem.getQuantity())));
    }
}
